package example.string;

/**
 * Created by lenovo on 2016/11/4 0004.
 */
public class Split {
    public static void main(String[] args) {
        String str = "www-runoob-com";
        String[] temp;//存储数组
        String delimeter = "-";//分隔符号
        temp = str.split(delimeter);
        //循环输出
        for (int i = 0; i < temp.length; i++) {
            System.out.println(temp[i]);
        }

        //foreach 方法
        System.out.println("===foreach方法===");
        String string = "www.runoob.com";
        String[] arr;
        arr = string.split("\\.");//java中，.符号属于特殊符号，想使用普通意思，需要转义
        for (String s :arr) {
            System.out.println(s);
        }
    }
}
